﻿using System;
using DomainExample.DomainModel.ContactModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DomainExample.Repository.Tests.ContactRepositoryTests
{
    [TestClass]
    public sealed class ContactRepositoryGetByIdTests : ContactRepositoryTests
    {
        [TestInitialize]
        public void SetUp()
        {
            CreateSchema();
        }

        [TestCleanup]
        public void TearDown()
        {
            DestroySchema();
        }

        [TestMethod]
        [TestCategory("Database Integration")]
        public void ContactRepositoryGetByIdWithIdExpectCorrectContact()
        {
            var expectedDate = DateTime.SpecifyKind(new DateTime(2012, 5, 12), DateTimeKind.Utc);
            var expectedType = ContactType.ElectronicMail;
            var expectedDirection = DirectionType.Inbound;
            const string expectedSummary = "Test summary";

            AddTestContact(DateTime.Now, ContactType.Telephone, DirectionType.Inbound, "Example");
            var testContact = AddTestContact(expectedDate, expectedType, expectedDirection, expectedSummary);
            AddTestContact(DateTime.Now, ContactType.Facsimile, DirectionType.Outbound, "Example");

            var result = Target.GetById(testContact.Id);

            Assert.AreEqual(expectedDate, result.DateUtc);
            Assert.AreEqual(expectedType, result.Type);
            Assert.AreEqual(expectedDirection, result.Direction);
            Assert.AreEqual(expectedSummary, result.Summary);
        }
    }
}
